<template>
  <div>
    <van-cell-group border>
      <van-field
        v-model="password"
        label="密码"
        placeholder="请设置密码"
        autofocus
      />
    </van-cell-group>
    <div class="nextbtn">
      <van-button
        type="danger"
        round
        block
        :disabled="flag"
        @click="register"
        >完成</van-button
      >
    </div>
  </div>
</template>

<script>
import {dofinishregister} from "../../api/user"
export default {
  data() {
    return {
      password: "",
    };
  },
  computed: {
    flag(){
      if(/^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])\S*$/.test(this.password)){
        return false;
      }else{
        return true;
      }
    }
  },
  methods: {
    register(){
      dofinishregister({tel:localStorage.getItem("tel"),password:this.password}).then(res=>{
        console.log(res.data.code);
        this.$router.go(-3)
      })
    }
  }
};
</script>

<style scoped>
.nextbtn {
  width: 80%;
  margin: 0.1rem auto;
}
</style>